import { createBrowserRouter, createRoutesFromElements, Route } from "react-router-dom";
import Error from "./Error";
import NotFound from "./NotFound";
import Projects from "./Projects";
import ProjectsList from "./ProjectsList";
import Root from "./Root";

const FetchWithRouter = createBrowserRouter(
  createRoutesFromElements(
    <Route path="/" element={<Root />} errorElement={<Error />} loader={() => Promise.resolve("root")}>
      <Route path="projects" element={<ProjectsList />} loader={() => Promise.resolve("projectsList")}>
        <Route path=":projectId" element={<Projects />} loader={() => Promise.resolve("projects")} />
      </Route>
      <Route index element={<NotFound />} />
    </Route>
  )
);
export default FetchWithRouter;
